package de.g18.llmaa.gui.workspace.internalFrame.product.key.verleihVerwaltung;

import java.awt.BorderLayout;
import java.awt.GridLayout;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import de.g18.llmaa.logic.vos.VOPerson;
import de.g18.llmaa.logic.vos.VOPerson_Schueler;

public class JPanel_Anzeigen_Schueler extends JPanel {

	private JPanel panel_GrundInfos;
	private JTextField textField_VorName;
	private JTextField textField_nachName;

	private VOPerson keyUser;

	public JPanel_Anzeigen_Schueler(VOPerson keyUser) {
		this.keyUser = keyUser;
		initGUI();

	}

	private void initGUI() {
		setLayout(new BorderLayout());
		add(getPanel_GrundInfos(), BorderLayout.NORTH);
		if (keyUser instanceof VOPerson_Schueler) {
			add(new Panel_Schueler());
		}

	}

	public JPanel getPanel_GrundInfos() {
		if (panel_GrundInfos == null) {
			panel_GrundInfos = new JPanel();
			panel_GrundInfos.setLayout(new GridLayout(2, 2));
			panel_GrundInfos.add(new JLabel("Vorname"));
			panel_GrundInfos.add(getTextField_VorName());
			panel_GrundInfos.add(new JLabel("Nachname"));
			panel_GrundInfos.add(getTextField_nachName());
		}
		return panel_GrundInfos;
	}

	public JTextField getTextField_VorName() {
		if (textField_VorName == null) {
			textField_VorName = new JTextField();
			textField_VorName.setText(keyUser.getVorName());
		}
		return textField_VorName;
	}

	public JTextField getTextField_nachName() {
		if (textField_nachName == null) {
			textField_nachName = new JTextField();
			textField_nachName.setText(keyUser.getNachName());
		}
		return textField_nachName;
	}

	class Panel_Schueler extends JPanel {

		VOPerson_Schueler schueler = (VOPerson_Schueler) keyUser;
		private JTextField textField_Klasse;
		private JTextField textField_DabeiSeit;
		private JTextField textField_DabeiBis;

		public Panel_Schueler() {
			initSchuelerPanel();
		}

		private void initSchuelerPanel() {
			setLayout(new GridLayout(3, 2));
			add(new JLabel("Klasse"));
			add(getTextField_Klasse());
			add(new JLabel("Schüler seit"));
			add(getTextField_DabeiSeit());
			add(new JLabel("Schüler bis"));
			add(getTextField_DabeiBis());
		}

		public JTextField getTextField_Klasse() {
			if (textField_Klasse == null) {
				textField_Klasse = new JTextField();
				textField_Klasse.setText(schueler.getKlasse().getKlassenName());
			}
			return textField_Klasse;
		}

		public JTextField getTextField_DabeiSeit() {
			if (textField_DabeiSeit == null) {
				textField_DabeiSeit = new JTextField();
				textField_DabeiSeit.setText(schueler.getSchuelerSeit() + "");
			}
			return textField_DabeiSeit;
		}

		public JTextField getTextField_DabeiBis() {
			if (textField_DabeiBis == null) {
				textField_DabeiBis = new JTextField();
				textField_DabeiBis.setText(schueler.getSchuelerBis() + "");
			}
			return textField_DabeiBis;
		}

	}
}
